<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/7/29 0029
 * Time: 下午 12:02
 */
namespace app\back\controller;
use app\model\Cate;

class Link extends BaseAdmin{

    function set_model()
    {
        $this->model=new \app\model\Link();
    }

    function list_init(){
        $model=$this->get_model();
        $data=$model->order("id","desc")->paginate();

        return [


            'list_title'=>['ID','连接','图片'],
            'list_data_name'=>['id','url','pic'],
            'type'=>[
                ['name'=>'pic','type'=>'image']
            ],
            'list_data'=>$data,
            'page_html'=>$model->paginate()->render(),
            'add_url'=>url('add')

        ];
    }

    function edit_init($id)
    {
        $model=$this->get_model();
        $info=$model->where(['id'=>$id])->find();



        return [
            'form'=>[
                ['name'=>'id','value'=>$info->id,'type'=>'hidden','label_title'=>""],

                ['name'=>'url','value'=>$info->url,'type'=>'text','label_title'=>"超连接"],
                ['name'=>'pic','value'=>$info->pic,'type'=>'pic_upload','label_title'=>"图片上传"],

            ],
            'form_action'=>url("edit_act"),
        ];
    }

    function add_init()
    {


        return [
            'form'=>[


                ['name'=>'url','value'=>"",'type'=>'text','label_title'=>"超连接"],
                ['name'=>'pic','value'=>"",'type'=>'pic_upload','label_title'=>"图片上传"],

            ],
            'form_action'=>url("add_act"),
        ];
    }

}